home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Sample Code / AppsToGo / DTS.Lib / DTS.Lib.headers / ListControl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-24  |  12.9 KB  |  271 lines  |  [TEXT/MPS ]

  1. #ifndef __LISTCONTROL__
  2. #define __LISTCONTROL__
  3.  
  4. #ifndef __TYPES__
  5. #include <Types.h>
  6. #endif
  7.  
  8. #ifndef __LISTS__
  9. #include <Lists.h>
  10. #endif
  11.  
  12. #ifndef __WINDOWS__
  13. #include <Windows.h>
  14. #endif
  15.  
  16. typedef void    (*CLGetCompareDataProcPtr)(void *src, short srclen, void *dst, short *dstlen);
  17. typedef short    (*CLDoCompareDataProcPtr)(void *ptra, void *ptrb, short lena, short lenb);
  18. typedef Boolean    (*CLKeyFilterProcPtr)(ListHandle list, EventRecord *event);
  19.  
  20. typedef struct CLDataRec {
  21.     short                    mode;
  22.     CLGetCompareDataProcPtr    getCompareData;
  23.     CLDoCompareDataProcPtr    doCompareData;
  24.     CLKeyFilterProcPtr        keyFilter;
  25. } CLDataRec;
  26. typedef CLDataRec *CLDataPtr, **CLDataHndl;
  27.  
  28. void            CLActivate(Boolean makeActive, ListHandle listHndl);
  29.     /* makeActive:    true to make the control the active control.
  30.     **                  false to inactivate the control.
  31.     ** ListHandle:    The list to activate or deactivate.
  32.     **
  33.     ** Activate this List record.  Activation is not done by calling LActivate().
  34.     ** The active control is indicated by the 2-pixel thick border around the
  35.     ** List control.  This allows all List controls in a window to display which
  36.     ** cells are selected.  This behavior can be overridden by calling LActivate()
  37.     ** on the List record for List controls.
  38.     ** Human interface dictates that at most only a single List control has this
  39.     ** active border.  For this reason, this function scans for other List
  40.     ** controls in the window and removes the border from any other that it finds. */
  41.  
  42. Boolean            CLClick(WindowPtr window, EventRecord *event, short *action);
  43.     /* window:    The window to check for a List control click in.
  44.     **
  45.     ** event:    The event record holding the mouseDown event.
  46.     **
  47.     ** action:    Used to return the action taken by CLClick.  (Pass in nil if you don't care.)
  48.     **            If 0 returned:     No action taken.
  49.     **            If 1 returned:     The active list control used the click.
  50.     **            If -1 returned:     A new List control was activated (and the old one deactivated.)
  51.     **
  52.     ** This is called when a mouseDown occurs in the content of a window.  It
  53.     ** returns true if the mouseDown caused a List action to occur.  Events
  54.     ** that are handled include if the user clicks on a scrollbar that is
  55.     ** associated with a List control. */
  56.  
  57. ControlHandle    CLCtlHit(void);
  58.     /* The List control that was hit by calling FindControl is saved in a
  59.     ** global variable, since the CDEF has no way of returning what kind it was.
  60.     ** To determine that it was a List control that was hit, first call this
  61.     ** function.  The first call returns the old value in the global variable,
  62.     ** plus it resets the global to nil.  Then call FindControl(), and then
  63.     ** call this function again.  If it returns nil, then a List control
  64.     ** wasn't hit.  If it returns non-nil, then it was a List control that
  65.     ** was hit, and specifically the one returned. */
  66.  
  67. Boolean            CLEvent(WindowPtr window, EventRecord *event, short *action);
  68.     /* window:    The window to check for a List control click in.
  69.     **
  70.     ** event:    The event record holding the mouseDown event.
  71.     **
  72.     ** action:    Used to return the action taken by CLClick.  (Pass in nil if you don't care.)
  73.     **            For click events:
  74.     **                If 0 returned:     No action taken.
  75.     **                If 1 returned:     The active list control used the click.
  76.     **                If -1 returned:     A new List control was activated (and the old one deactivated.)
  77.     **            For key events:
  78.     **                If 0 returned:     No action taken.
  79.     **                If 1 returned:     Key positioning occured on the active control.
  80.     **
  81.     ** Handle the event if it applies to the active List control.  If some
  82.     ** action occured due to the event, return true. */
  83.  
  84. ListHandle        CLFindActive(WindowPtr window);
  85.     /* Returns the active List control, if any.  If nil is passed in, then
  86.     ** the return value represents whatever List control is active, independent
  87.     ** of what window it is in.  If a window is passed in, then it returns a
  88.     ** List control only if the active control is in the specified window.
  89.     ** If the active List control is in some other window, then nil is returned. */
  90.  
  91. ControlHandle    CLFindCtl(WindowPtr window, EventRecord *event, ListHandle *listHndl, ControlHandle *ctlHit);
  92.     /* This determines if a List control was clicked on, or if a related scrollbar was
  93.     ** clicked on.  If a List control or List scrollbar was clicked on, then true is returned,
  94.     ** as well as the List handle and the handle to the view control. */
  95.  
  96. ListHandle        CLFromScroll(ControlHandle scrollCtl, ControlHandle *retCtl);
  97.     /* Find the List record that is related to the indicated scrollbar. */
  98.  
  99. ListHandle        CLGetList(WindowPtr window, short lnum);
  100. /* Get the Nth List control in the control list of a window. */
  101.  
  102. short            CLInsert(ListHandle listHndl, char *data, short dataLen, short row, short col);
  103.     /* Insert a cell alphabetically into the list.  Whichever parameter is passed in
  104.     ** as -1, either row or column, that is the dimension that is determined.  The method of
  105.     ** handling he comparisons has been changed to allow customization of the list data and
  106.     ** search methods.  Before, it was assumed that the cell content was text, and that the
  107.     ** default LDEF was being used.  If you write a custom LDEF that uses a different data
  108.     ** format, you had problems before.  Now, with the addition of two procedure pointers, you
  109.     ** can customize the data comparisons.
  110.     ** The two new procs are:
  111.     **      1) getCompareData
  112.     **      2) doCompareData
  113.     ** The first proc, getCompareData, if nil, simply gets the data out of the cell for
  114.     ** comparison purposes.  If it is not nil, then the proc is called, and the proc gets
  115.     ** the data out of the cell.  The proc can then get whatever data it needs to for the
  116.     ** purpose of comparing to other cells and finding the insert location in the list.
  117.     ** The second proc, doCompareData, if nil tells the List control to call IUMagString
  118.     ** for the purpose of comparison.  If it is not nil, then the proc is called instead of
  119.     ** IUMagString, and you can do whatever kind of comparison you wish.  Your proc is a
  120.     ** replacement for IUMagString, so it should be of that form, except that the prototype
  121.     ** is a C prototype, instead of type pascal.
  122.     **
  123.     ** The prototypes are:
  124.     **
  125.     ** typedef void  (*CLGetCompareDataProcPtr)(void *src, short srclen, void *dst, short *dstlen);
  126.     ** typedef short (*CLDoCompareDataProcPtr)(void *ptra, void *ptrb, short lena, short lenb);
  127.     **
  128.     ** The GetCompareData proc is passed in a reference to the data, and a length.  Its job is to
  129.     ** then return the data and data length of what the compare data should look like.
  130.     **
  131.     ** The DoCompareData proc is just a replacement for IUMagString.  Parameters are as expected.
  132.     ** To set the procs, you first need to have a List control.  The below example assumes that
  133.     ** the window has a single List control.
  134.     **
  135.     **
  136.     ** static short        MyDoCompareData(void *ptra, void *ptrb, short lena, short lenb);
  137.     ** static void        MyGetCompareData(void *src, short srclen, void *dst, short *dstlen);
  138.     ** static Boolean    MyKeyFilter(ListHandle list, EventRecord *event);
  139.     **
  140.     ** ControlHandle    ctl;
  141.     ** ListHandle        list;
  142.     ** CLDataHndl        listData;
  143.     **
  144.     ** ctl = CLNext(window, &list, nil, 1, false);         Get first (only) List control in window.
  145.     ** listData = (CLDataHndl)(*ctl)->contrlData;         Get the listData handle for the control.
  146.     ** (*listData)->getCompareData = MyGetCompareData;   Set the procs.
  147.     ** (*listData)->getCompareData = MyDoCompareData;
  148.     ** (*listData)->keyFilter      = MyKeyFilter;
  149.     */
  150.  
  151. Boolean            CLKey(WindowPtr window, EventRecord *event);
  152.     /* See if the keypress event applies to the List control, and if it does, handle it and
  153.     ** return true.  The keypress can only be used by the List control if the List control
  154.     ** has key-positioning set. */
  155.  
  156. ListHandle        CLNew(short viewID, Boolean vis, Rect *vRect, short numRows, short numCols,
  157.                       short cellHeight, short cellWidth, short theLProc,
  158.                       WindowPtr window, short mode);
  159.     /* Create a new List control.  See ā€œ=Using ListControl.cā€ for how to use this call. */
  160.  
  161. ControlHandle    CLNext(WindowPtr window, ListHandle *listHndl, ControlHandle ctl,
  162.                        short dir, Boolean justActive);
  163.     /* Get the next List control in the window.  You pass it a control handle
  164.     ** for the view control, or nil to start at the beginning of the window.
  165.     ** It returns both a List handle and the view control handle for that
  166.     ** List record.  If none is found, nil is returned.  This allows you to
  167.     ** repeatedly call this function and walk through all the List controls
  168.     ** in a window. */
  169.  
  170. void            CLPrint(RgnHandle clipRgn, ListHandle listHndl, short *row, short *col,
  171.                         short leftEdge, Rect *drawRct);
  172.     /* From the starting for or column, print as many cells as will fit into the
  173.     ** designated rect.  Pass in a starting row and column, and they will be
  174.     ** adjusted to indicate the first cell that didn't fit into the rect.  If all
  175.     ** remaining cells were printed, the row is returned as -1.  The bottom of the
  176.     ** rect to print in is also adjusted to indicate where the actual cut-off
  177.     ** point was. */
  178.  
  179. short            CLRowOrColSearch(ListHandle listHndl, void *data, short dataLen,
  180.                                  short row, short col);
  181.     /* Find the location in the list where the data would belong if inserted.  The row
  182.     ** and column are passed in.  If either is -1, that is the dimension that will be
  183.     ** determined and returned.  The two comparison procs getCompareData and doCompareData are
  184.     ** used in this function.  See CLInsert for a description of these procs. */
  185.  
  186. void            CLUpdate(RgnHandle clipRgn, ListHandle list);
  187.     /* Draw the List control in the correct form. */
  188.  
  189. ControlHandle    CLViewFromList(ListHandle listHndl);
  190.     /* Return the control handle for the view control that owns the List
  191.     ** record.  Use this to find the view to do customizations such as changing
  192.     ** the update procedure for this List control. */
  193.  
  194. ListHandle        CLWindActivate(WindowPtr window, Boolean displayIt);
  195.     /* This window is becoming active or inactive.  The borders of the List
  196.     ** controls need to be redrawn due to this.  For each List control in the
  197.     ** window, redraw the active border. */
  198.  
  199. void            CLSize(ListHandle list, short newH, short newV);
  200.     /* This resizes the list and it's viewCtl. */
  201.  
  202. void            CLMove(ListHandle list, short newH, short newV);
  203.     /* This moves the list and its viewCtl. */
  204.  
  205. void            CLShow(ListHandle list);
  206. Rect            CLHide(ListHandle list);
  207.  
  208. void            CLVInitialize(void);
  209.     /* Call this upon startup of any application that wants to be able to use the
  210.     ** variable-size cell feature of the List control.  For AppsToGo-created List control
  211.     ** definitions to be variable-size automatically, this must be called first.
  212.     ** You can call CLVVariableSizeCells() at a later time to utilize this feature, as it
  213.     ** calls CLVInitialize(). */
  214.  
  215. void            CLVVariableSizeCells(ListHandle list);
  216.     /* This is called to convert a List control to one that has variable size rows and columns. */
  217.  
  218.  
  219. void            CLVAdjustScrollBars(ListHandle list);
  220. void            CLVFindCell(ListHandle list, Point mouseLoc, Point *cell);
  221. void            CLVGetCellRect(ListHandle list, short xx, short yy, Rect *cbnds);
  222. void            CLVGetVisCells(ListHandle list, Rect *visRct);
  223. void            CLVGetCellInfo(ListHandle list, short xx, short yy, Rect *cbnds, short *cellNum,
  224.                                short *select, short *ofst, short *len);
  225. void            CLVSetSelect(Boolean select, Point cell, ListHandle list);
  226. void            CLVAutoScroll(ListHandle list);
  227.  
  228. void            CLVAdjustCellLocs(ListHandle list);
  229. short            CLVAddColumn(short count, short colNum, short ww, ListHandle list);
  230. short            CLVAddRow(short count, short colNum, short hh, ListHandle list);
  231. void            CLVDraw(Point cell, ListHandle list);
  232.  
  233. Boolean            CLVClick(Point mouseLoc, short modifiers, ListHandle list);
  234. void            CLVUpdate(RgnHandle clipRgn, ListHandle list);
  235. void            CLVCallDefProc(short lMessage, short lSelect, Rect *lRect, Cell lCell,
  236.                                short lDataOffset, short lDataLen, ListHandle list);
  237.  
  238.  
  239. typedef void            (*CLActivateProcPtr)(Boolean active, ListHandle listHndl);
  240. typedef Boolean            (*CLClickProcPtr)(WindowPtr window, EventRecord *event, short *action);
  241. typedef ControlHandle    (*CLCtlHitProcPtr)(void);
  242. typedef ListHandle        (*CLFindActiveProcPtr)(WindowPtr window);
  243. typedef Boolean            (*CLKeyProcPtr)(WindowPtr window, EventRecord *event);
  244. typedef ControlHandle    (*CLNextProcPtr)(WindowPtr window, ListHandle *listHndl, ControlHandle ctl, short dir, Boolean justActive);
  245. typedef ControlHandle    (*CLViewFromListProcPtr)(ListHandle listHndl);
  246. typedef ListHandle        (*CLWindActivateProcPtr)(WindowPtr window, Boolean displayIt);
  247.  
  248. typedef void            (*CLVVariableSizeCellsProcPtr)(ListHandle list);
  249. typedef void            (*CLVGetCellRectProcPtr)(ListHandle list, short xx, short yy, Rect *cbnds);
  250. typedef void            (*CLVUpdateProcPtr)(RgnHandle clipRgn, ListHandle list);
  251. typedef void            (*CLVAutoScrollProcPtr)(ListHandle list);
  252. typedef void            (*CLVSetSelectProcPtr)(Boolean select, Point cell, ListHandle list);
  253. typedef Boolean            (*CLVClickProcPtr)(Point mouseLoc, short modifiers, ListHandle list);
  254. typedef void            (*CLVAdjustScrollBarsProcPtr)(ListHandle list);
  255.  
  256.  
  257. #define rListCtl        4016
  258.  
  259. #define clHScroll        0x0002
  260. #define clVScroll        0x0008
  261. #define clActive        0x0020
  262. #define clShowActive    0x0040
  263. #define clKeyPos        0x0080
  264. #define clTwoStep        0x0100
  265. #define clHasGrow        0x0200
  266. #define clVariable        0x4000
  267. #define clDrawIt        0x8000
  268.  
  269. #endif
  270.  
  271.